import opengraph.api.HtmlFetcher
import opengraph.api.OpenGraph
import opengraph.impl.HtmlFetcherImpl
import opengraph.impl.HtmlParserImpl
import opengraph.impl.basic
import opengraph.impl.def
import java.io.BufferedInputStream
import java.io.BufferedReader
import java.io.ByteArrayInputStream
import java.io.InputStream
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL
import java.nio.charset.Charset


fun main() {
//    OpenGraph.get("https://baidu.com"){
//
//        println("err")
//    }?.let {
//        println(it)
//    }


    val data = OpenGraph.builder()
        .setHtmlFetcher(object : HtmlFetcher {
            override fun fetch(url: String): String {
                return """
                    <html prefix=
            "og: https://ogp.me/ns# 
             schema: http://schema.org/ 
             dc: http://purl.org/dc/terms/ 
             foaf: http://xmlns.com/foaf/0.1/ 
             gr: http://purl.org/goodrelations/v1#">
                    <title>工作台 - Gitee.com</title>
                    <link rel="shortcut icon" href="/favicon.ico">
                    <meta name="description" content="Gitee.com（码云） 是 OSCHINA.NET 推出的代码托管平台，支持 Git 和 SVN，提供免费的私有仓库托管。目前已有超过 1200 万的开发者选择 Gitee。">
                    <meta name="name" content="name222" />
                    <meta property='og:title' content='hhghgh' />
                    <meta property="og:title" content="The Rock" />
                    <meta property="og:title" content="The Rock" />
                    <meta property="og:title" content="The Rock2" />
                    <meta property="og:type" content="video.movie" />
                    <meta property="og:url" content="https://www.imdb.com/title/tt0117500/" />
                    <meta property="og:url:temp" content="https://www.imdb.com/title/tt0117500/" />
                    <meta property="og:image" content="https://ia.media-imdb.com/images/rock.jpg" />
                    <meta property="og:image:url" content="https://ia.media-imdb.com/images/rock.jpg" />
                    <meta property="og:image:width" content="10" />
                """.trimIndent()
            }
        })
        .build()
        .get("https://tongyi.aliyun.com/")


    println(data.basic())
    println(data.def())
}


